package voa;

import java.io.File;
import java.util.List;
import util.FileProcessor;

public class KindleDirProcessor implements FileProcessor {

	public void process(File dir) {

		if (dir.isDirectory()) {

			LrcFiles lrcFiles = LrcFiles.instance(dir.getAbsolutePath());

			List fileList = lrcFiles.getFileList();

			if (fileList.size() > 0) {

				for (int i = 0; i < fileList.size(); i++) {
					
					File file = (File) fileList.get(i);
					
					getProcessor().process(file);
					
					String outFileName = ((KindleFileProcessor)getProcessor()).getOutputPath(file);
					lrcFiles.getTmpFiles().add(new File(outFileName));
				}

				lrcFiles.genPublishFiles();

				lrcFiles.clean();
			}

		}
	}
	
	private FileProcessor getProcessor(){
		
		return new KindleFileProcessor();
	}
	
}
